<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){//操作
        $list = M('List'); //表名字 
        $rows = $list->select(); 
        $this->assign('rows', $rows);
        //$row = $list->find(20); 
        //print_r($rows);
        $this->display('index');

    }
    //添加的视图控制器
    public function add(){
        //include "../View/List/listAddView.html"; 

        //分配视图
        //$this->display('listAddView');  /View/Index/listAddView
        //$this->display('test'); 
        $this->display();  //  View/当前控制器/当前操作
    }
    //添加的模型控制器
    public function addDo(){
       $data = $_POST; 
       $list = M('List'); //表名字
       $list->add($data);
    }
    public function edit(){
        $id = $_GET['id'];
        $list = M('List'); //表名字
        $row = $list->find($id);

        $this->assign('row', $row);
        $this->display('edit');
    }
    public function editDo(){
        $data = $_POST;
        $list = M('List'); //表名字
        $res = $list->save($data);
        //var_dump($res);

        //print_r($_POST);
    }
    public function delDo(){
        //print_r($_GET);
        $id = $_GET['id'];
        $list = M('List'); //表名字
        $list->delete($id);

        //M('List')->delete($_GET['id']);
    }
}
